package com.hspedu.static_;

public class ChildGame {
    public static void main(String[] args) {
        int count = 0;
        Child child = new Child("白骨精");
        child.join();
        //count++;

        Child child2 = new Child("狐狸精");
        child2.join();
        //count++;

        Child child3 = new Child("老鼠精");
        child3.join();
        //count++;
        System.out.println("共有 " + child.count + " 个小孩加入游戏！");
    }

}


class Child{
    private String name;
    //定义一个变量 count,是一个类的变量(静态变量) static静态
    //该变量的最大的特点会被这个对象所有的实例共享！
    public static int count = 0;
    public Child(String name) {
        this.name = name;
    }

    public void join(){
        count++;
        System.out.println(this.name + " 加入了游戏..");
    }

}
